package com.whfc.ms.api.fse.service.impl;

import com.whfc.common.result.ListData;
import com.whfc.common.result.PageData;
import com.whfc.common.util.DateUtil;
import com.whfc.entity.dto.warn.AppWarnRuleDTO;
import com.whfc.entity.param.warn.AppWarnHandleParam;
import com.whfc.fse.dto.FseCraneWarnCountDTO;
import com.whfc.fse.dto.FseWarnDetailDTO;
import com.whfc.fse.dto.FseWarnRecordDTO;
import com.whfc.fse.param.FseWarnSetUserParam;
import com.whfc.fse.param.WarnBatchDelParam;
import com.whfc.fse.param.WarnBatchHandleParam;
import com.whfc.fse.service.FseWarnService;
import com.whfc.fuum.entity.SysUser;
import com.whfc.ms.api.fse.service.MsFseWarnService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @DESCRIPTION
 * @AUTHOR GuoDong_Sun
 * @DATE 2020/4/13
 */
@Service
public class MsFseWarnServiceImpl implements MsFseWarnService {

    @DubboReference(interfaceClass = FseWarnService.class, version = "1.0.0")
    private FseWarnService fseWarnService;

    @Override
    public ListData<AppWarnRuleDTO> ruleList(Integer deptId, Integer type) {
        return fseWarnService.ruleList(deptId, type);
    }

    @Override
    public void userAdd(FseWarnSetUserParam request) {
        fseWarnService.userAdd(request);
    }


    @Override
    public PageData<FseWarnRecordDTO> recordList(Integer deptId, Integer pageNum, Integer pageSize, Integer state, Integer ruleType, Integer type, Date startTime, Date endTime) {
        return fseWarnService.recordList(deptId, pageNum, pageSize, state, ruleType, type, startTime, endTime);
    }

    @Override
    public FseWarnDetailDTO recordDetail(Integer id) {
        return fseWarnService.recordDetail(id);
    }

    @Override
    public void recordHandle(SysUser user, AppWarnHandleParam request) {
        fseWarnService.recordHandle(user, request);
    }

    @Override
    public void batchHandle(WarnBatchHandleParam param) {
        fseWarnService.batchHandle(param);
    }

    @Override
    public void del(WarnBatchDelParam param) {
        fseWarnService.del(param);
    }

    @Override
    public FseCraneWarnCountDTO countCraneWarn(Integer craneId) {
        Date date = new Date();
        Date startTime = DateUtil.getDateBegin(date);
        Date endTime = DateUtil.getDateEnd(date);
        return fseWarnService.getCraneWarnCount(craneId, startTime, endTime);
    }
}

